import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/hj_page/mine_business/ai/ai_sub_type/ai_function_Logic.dart';
import 'package:tiktokadult/tools_base/loading/l_error_widget.dart';

//ai视频/图片换脸
class AIChangeFaceSubPage extends StatefulWidget {
  final AIFunctionType type;
  const AIChangeFaceSubPage({super.key, required this.type});

  @override
  State<AIChangeFaceSubPage> createState() => _AIChangeFaceSubPageState();
}

class _AIChangeFaceSubPageState extends State<AIChangeFaceSubPage> {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<AIFunctionBaseLogic>(
        global: false,
        init: instanceController(null, widget.type),
        builder: (controller) {
          if (controller.rawDataModel == null) return CErrorWidget();
          return GridView.builder(
            padding: EdgeInsets.symmetric(horizontal: 16),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: controller.crossAxisCount,
              crossAxisSpacing: controller.spaceW,
              mainAxisSpacing: controller.spaceH,
              childAspectRatio: controller.ratio,
            ),
            itemCount: controller.dataSource.length,
            itemBuilder: (BuildContext context, int index) {
              return controller.instanceChild(index);
            },
          );
        });
  }
}
